
import { createRender } from '../runtime-core/index'
import { nodeOps } from './nodeOps'
import { patchProp } from './patchProp'


const renderOptions = {...nodeOps, patchProp}

function ensureRenderer() {
  return createRender(renderOptions)
}

export function createApp(rootComponent){

  // 1.根据组件，创建一个渲染器
  const app = ensureRenderer().createApp(rootComponent);

  const {mount} = app

  app.mount = function (container) {
    container = document.querySelector(container)
    container.innerHTML = ''
    // 1.挂载的时候要先清空
    mount(container)
  }

  return app
}